<template>
	<view class="content">
		<view class="headBox">
			<image :src="baseurl+'user/bg1.jpg'" class="bg"></image>
			<image :src="userInfo.avatar" class="avatar"
				@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/setting/setting')">
			</image>
			<text class="name">{{userInfo.nickname}}</text>
			<image :src="baseurl+'user/scan.png'" class="scan" v-if="userInfo.is_role==1" @click="scan()"></image>
			<view class="medalBox"
				@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/medal/medal')">
				<view class="label">勋章</view>
				<view class="num">{{userInfo.medal}}</view>
			</view>
			<view class="followBox"
				@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/my_follow/my_follow')">
				<view class="label">关注</view>
				<view class="num">{{userInfo.follow_num}}</view>
			</view>
			<view class="postBox"
				@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/my_post/my_post')">
				<view class="label">帖子</view>
				<view class="num">{{userInfo.article_num}}</view>
			</view>
			<image :src="baseurl+'user/renzheng.png'" class="renzheng" @click="certification()"
				v-if="userInfo.authentication_status==='' || userInfo.authentication_status==2">
			</image>
			<image :src="baseurl+'user/yirenzheng.png'" class="renzheng" v-else-if="userInfo.authentication_status==1">
			</image>
			<image :src="baseurl+'user/shenhezhong.png'" class="renzheng"
				v-else-if="userInfo.authentication_status===0">
			</image>
			<!-- <image :src="baseurl+'user/renzheng.png'" class="renzheng"
				@click="$u.toast('系统维护中，暂时无法认证')">
			</image> -->
		</view>
		<!-- 我的订单 -->
		<view class="myOrderBox">
			<view class="labelBox">
				<view class="line"></view>
				<text class="label">我的订单</text>
			</view>
			<!-- <image :src="baseurl+'user/3.png'" class="myOrderBoxLabel"></image> -->
			<text class="all"
				@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_order/user_order')">全部></text>
			<view class="myOrderMenuBox">
				<view class="myOrderMenu1 myOrderMenu"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_order/user_order',{type:'pay'})">
					<image :src="baseurl+'user/icon1.png'" class="orderImg" />
					<text class="menuLabel">待付款</text>
					<view class="subscriptBox" v-if="userInfo.wait_pay>0">
						{{userInfo.wait_pay}}
					</view>
				</view>
				<view class="myOrderMenu2 myOrderMenu"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_order/user_order',{type:'delivery'})">
					<image :src="baseurl+'user/icon2.png'" class="orderImg" />
					<text class="menuLabel">待发货</text>
					<view class="subscriptBox" v-if="userInfo.wait_delivery>0">
						{{userInfo.wait_delivery}}
					</view>
				</view>
				<view class="myOrderMenu3 myOrderMenu"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_order/user_order',{type:'delivery'})">
					<image :src="baseurl+'user/icon3.png'" class="orderImg" />
					<text class="menuLabel">待收货</text>
					<view class="subscriptBox" v-if="userInfo.wait_take>0">
						{{userInfo.wait_take}}
					</view>
				</view>
				<view class="myOrderMenu3 myOrderMenu"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_order/user_order',{type:'finish'})">
					<image :src="baseurl+'user/icon4.png'" class="orderImg" />
					<text class="menuLabel">待评论</text>
					<view class="subscriptBox" v-if="userInfo.wait_take>0">
						{{userInfo.wait_take}}
					</view>
				</view>
			</view>
		</view>
		<view class="myServeBox">
			<view class="labelBox">
				<view class="line"></view>
				<text class="label">社群功能</text>
			</view>
			<view class="myServeMenuBox">
				<view class="myServeItem" style="margin-bottom: 0;"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/my_association/my_association')">
					<image :src="baseurl+'user/icon16.png'" class="serveImg" />
					<text class="menuLabel">我的社群</text>
				</view>
				<view class="myServeItem" style="margin-bottom: 0;"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/my_activity/my_activity')">
					<image :src="baseurl+'user/icon9.png'" class="serveImg" />
					<text class="menuLabel">我的活动</text>
				</view>
				<view class="myServeItem" style="margin-bottom: 0;"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/association_examine/association_examine')">
					<image :src="baseurl+'user/icon16.png'" class="serveImg" />
					<text class="menuLabel">主理人审核</text>
					<view class="subscriptBox" v-if="waitCheck>0">
						{{waitCheck}}
					</view>
				</view>
				<view class="myServeItem" style="margin-bottom: 0;">
				</view>
			</view>
		</view>
		<!-- 我的服务 -->
		<view class="myServeBox">
			<view class="labelBox">
				<view class="line"></view>
				<text class="label">常用功能</text>
			</view>
			<view class="myServeMenuBox">
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/invite_poster/invite_poster')">
					<image :src="baseurl+'user/icon5.png'" class="serveImg" />
					<text class="menuLabel">邀请海报</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_address/user_address')">
					<image :src="baseurl+'user/icon6.png'" class="serveImg" />
					<text class="menuLabel">收货地址</text>
				</view>
				<view class="myServeItem" v-if="isTab==1"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/business_certification/business_certification')">
					<image :src="baseurl+'user/icon7.png'" class="serveImg" />
					<text class="menuLabel">商家入驻</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_collection/user_collection')">
					<image :src="baseurl+'user/icon8.png'" class="serveImg" />
					<text class="menuLabel">我的收藏</text>
				</view>

				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/my_order/my_order')">
					<image :src="baseurl+'user/icon10.png'" class="serveImg" />
					<text class="menuLabel">我的预约</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/integral_details/integral_details')">
					<image :src="baseurl+'user/icon11.png'" class="serveImg" />
					<text class="menuLabel">积分记录</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/message/message')">
					<image :src="baseurl+'user/icon12.png'" class="serveImg" />
					<text class="menuLabel">消息通知</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/bundle/pages/user_coupon/user_coupon')">
					<image :src="baseurl+'user/icon15.png'" class="serveImg" />
					<text class="menuLabel">优惠券</text>
				</view>
				<view class="myServeItem">
					<image :src="baseurl+'user/icon13.png'" class="serveImg" />
					<button open-type='contact' class="service"></button>
					<text class="menuLabel">联系客服</text>
				</view>
				<view class="myServeItem"
					@click="login===false?$navto.navto('/packageB/login/login'):$navto.navto('/packageB/feedback/feedback')">
					<image :src="baseurl+'user/icon14.png'" class="serveImg" />
					<text class="menuLabel">意见反馈</text>
				</view>
				<!-- v-if="userInfo.community==1" -->

				<view class="myServeItem">
				</view>
				<view class="myServeItem">
				</view>
			</view>
		</view>
		<view class="tabBarBox" v-if="isTab==1">
			<image src="@/static/tab/bg.png" class="tabbg"></image>
			<image src="@/static/tab/1.png" class="projectTab" @click="$redirectTo('/packageB/project/project')">
			</image>
			<image src="@/static/tab/2.png" class="associationTab"
				@click="$redirectTo('/packageB/association/association')"></image>
			<image src="@/static/tab/3.png" class="homeTab" @click="$redirectTo('/pages/index/index')"></image>
			<image src="@/static/tab/4.png" class="mallTab" @click="$redirectTo('/packageB/category/category')"></image>
			<image src="@/static/tab/5s.png" class="myTab" @click="$redirectTo('/pages/user/user')"></image>
		</view>
		<view class="tabBarBox" v-else>
			<image src="@/static/tab/bg.png" class="tabbg"></image>
			<image src="@/static/tab/1.png" class="projectTab" @click="$redirectTo('/packageB/project/project')">
			</image>
			<!-- <image src="@/static/tab/2.png" class="associationTab"@click="$redirectTo('/packageB/association/association')"></image> -->
			<image src="@/static/tab/3.png" class="homeTab" @click="$redirectTo('/pages/index/index')"></image>
			<!-- <image src="@/static/tab/4.png" class="mallTab" @click="$redirectTo('/packageB/category/category')"></image> -->
			<image src="@/static/tab/5s.png" class="myTab" @click="$redirectTo('/pages/user/user')"></image>
		</view>
	</view>
</template>
<script>
	import Cache from '@/utils/cache'
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	const app = getApp()
	export default {
		data() {
			return {
				baseurl: this.$baseurl,
				login: '',
				isTab: '',
				waitCheck:0
			}
		},

		onLoad(options) {
			// 获取待审核列表数据
			this.$request.get(`CommunityUser/audit_list?page=${this.page}`).then(res => {
				// 追加数据
				this.waitCheck=res.data.count;
			})
			// this.$request.get(`Community/submit_status`).then(res => {
			this.isTab = getApp().globalData.isTab;
			// if (!this.login) {
			// 	console.log("未登录")
			// 	this.$navto.navto('/packageB/login/login');
			// 	this.$Router.push('/packageB/login/login')
			// 	return false
			// }
			// })
		},
		onShow() {
			this.$request.get(`Community/submit_status`).then(res => {
				this.isTab = res.data.data;
			})
			this.login = this.isLogin;
			console.log(this.login);
			this.getUser()
			if (!this.login) {
				console.log("未登录")
				this.$navto.navto('/packageB/login/login');
				this.$Router.push('/packageB/login/login')
				return false
			}
		},
		methods: {
			...mapActions(['getCartNum', 'getUser']),
			certification() {
				//业主认证
				console.log(this.userInfo);
				if (!this.login) {
					console.log("未登录")
					this.$navto.navto('/packageB/login/login');
					this.$Router.push('/packageB/login/login')
					return false
				} else {
					if (this.userInfo.authentication_status == 0) {
						this.$navto.navto('/packageB/owner_certification/owner_certification');
					} else {
						this.$u.toast('您已经认证过了');
					}
				}
			},
			scan() {
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('条码内容：' + res.result);
						let params = res.result.split('&');
						console.log(params[0]);
						if (params[0] == 1) { //看房预约
							uni.navigateTo({
								url: `/packageB/my_order_hexiao/my_order_hexiao?id=${params[1]}`
							});
						} else if (params[0] == 2) { //活动
							uni.navigateTo({
								url: `/packageB/my_activity_hexiao/my_activity_hexiao?id=${params[1]}`
							});
						}
					}
				});
			},
		},
		computed: {
			...mapGetters(['userInfo', 'inviteCode', 'appConfig']),
		}
	}
</script>
<style lang="scss">
	.labelBox {
		display: flex;
		align-items: center;

		.line {
			width: 8rpx;
			height: 20rpx;
			background-color: #73A7B7;
		}

		.label {
			font-size: 24rpx;
			font-weight: 700;
			margin-left: 20rpx;
		}
	}

	.scan {
		position: absolute;
		width: 40rpx;
		height: 40rpx;
		right: 55rpx;
		top: 235rpx;
	}

	.menuLabel {
		width: 100%;
		text-align: center;
		font-size: 24rpx;
		font-weight: 500;
		position: absolute;
		bottom: 0;
		left: 0;
	}

	.service {
		position: absolute;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
	}

	.myServeBox {
		position: relative;
		width: 670rpx;
		// height: 600rpx;
		margin-top: 90rpx;
		margin-bottom: 80rpx;

		.myServeLabel {
			width: 135rpx;
			height: 22rpx;
		}

		.myServeMenuBox {
			width: 624rpx;
			margin-top: 60rpx;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			margin-left: 66rpx;

			.myServeItem {
				position: relative;
				width: 128rpx;
				height: 116rpx;
				margin-bottom: 80rpx;
				display: flex;
				justify-content: center;
				.subscriptBox {
					position: absolute;
					top: -10rpx;
					right: -10rpx;
					padding: 8rpx;
					border-radius: 50%;
					background-color: red;
					font-size: 17rpx;
					color: #fff;
					height: 30rpx;
					width: 30rpx;
					/* text-align: center; */
					display: flex;
					/* line-height: 35rpx; */
					align-items: center;
					justify-content: center;
				}
				.serveImg {
					width: 100rpx;
					height: 130rpx;
				}

				.subscriptBox {
					top: -5rpx;
					right: 20rpx;
					position: absolute;
					padding: 8rpx;
					border-radius: 50%;
					background-color: red;
					font-size: 17rpx;
					color: #fff;
					height: 30rpx;
					width: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}

			.myServeItemLast {
				position: absolute;
				width: 120rpx;
				height: 116rpx;
				top: 524rpx;
				left: 231rpx;
			}
		}
	}

	.myOrderBox {
		position: relative;
		width: 710rpx;
		height: 190rpx;
		margin-top: 70rpx;
		margin-left: 0rpx;

		.myOrderBoxLabel {
			width: 135rpx;
			height: 22rpx;
		}

		.myOrderMenuBox {
			width: 584rpx;
			height: 105rpx;
			margin-top: 60rpx;
			margin-left: 85rpx;
			display: flex;
			justify-content: space-between;

			.myOrderMenu {
				position: relative;
				width: 75rpx;
				height: 100%;

				.orderImg {
					width: 75rpx;
					height: 105rpx;
				}

				.subscriptBox {
					position: absolute;
					top: -10rpx;
					right: -10rpx;
					padding: 8rpx;
					border-radius: 50%;
					background-color: red;
					font-size: 17rpx;
					color: #fff;
					height: 30rpx;
					width: 30rpx;
					/* text-align: center; */
					display: flex;
					/* line-height: 35rpx; */
					align-items: center;
					justify-content: center;
				}
			}
		}

		.all {
			position: absolute;
			font-size: 20rpx;
			color: #8C8C8C;
			right: 39rpx;
			top: 0;
		}
	}

	.renzheng {
		position: absolute;
		left: 40rpx;
		bottom: 0rpx;
		width: 674rpx;
		height: 220rpx;
	}

	.headBox {
		width: 100%;
		height: 618rpx;
		position: relative;

		.postBox {
			position: absolute;
			left: 570rpx;
			top: 320rpx;
			display: flex;
			align-items: center;
		}

		.followBox {
			position: absolute;
			left: 397rpx;
			top: 320rpx;
			display: flex;
			align-items: center;
		}

		.medalBox {
			position: absolute;
			left: 222rpx;
			top: 320rpx;
			display: flex;
			align-items: center;
		}

		.label {
			display: block;
			font-size: 22rpx;
			font-weight: 500;
			color: #fff;
		}

		.num {
			display: block;
			font-size: 40rpx;
			font-weight: 700;
			color: #87CADE;
			margin-left: 20rpx;
		}

		.name {
			position: absolute;
			left: 222rpx;
			top: 232rpx;
			font-size: 36rpx;
			font-weight: 700;
			color: #fff;
		}

		.avatar {
			position: absolute;
			width: 130rpx;
			height: 130rpx;
			left: 37rpx;
			top: 222rpx;
			border-radius: 50%;
		}

		.bg {
			position: absolute;
			width: 100%;
			height: 528rpx;
			left: 0;
			top: 0;
		}
	}

	page {
		width: 100%;
		height: 100%;
		background-color: #fff;
	}

	.content {
		width: 100%;
		height: 90vh;
		background-color: #fff;
		overflow-y: scroll;
		padding-bottom: 100rpx;
	}
</style>